package com.ykq.service.impl;

import com.ykq.dao.StaffDao;
import com.ykq.entity.Staff;
import com.ykq.service.StaffService;
import com.ykq.util.CommonResult;
import com.ykq.util.WebUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @program: qy145-key
 * @description:
 * @author: 闫克起2
 * @create: 2021-12-16 10:32
 **/
@Service(value = "staffService")
public class StaffServiceImpl implements StaffService {

    @Autowired
    private StaffDao staffDao;

    public CommonResult findByUsernameAndPassword(String username, String password) {
        Staff staff=staffDao.selectByUsernameAndPasasword(username,password);
        if(staff==null){
             return new CommonResult(5000,"账号或密码错误",null);
        }
        WebUtil.getSession().setAttribute("staff",staff);
        return new CommonResult(2000,"登录成功",null);
    }
}
